<!-- 公告内容列表 -->
<template>
    <el-collapse modelValue="1">
        <el-collapse-item title="添加内容" name="1">
            <si-collapse-group
                v-model="list"
                is-draggable
                is-add
                is-delete
                add-text="添加公告"
                :add="getAddData"
                :node-title="data => data.secContent"
            >
                <template #item="{ element, index }">
                    <div class="row-wrap">
                        <el-input
                            v-model="element.secContent"
                            :autosize="{ minRows: 4, maxRows: 4 }"
                            type="textarea"
                            placeholder="请输入公告内容"
                        >
                        </el-input>
                    </div>

                    <el-divider></el-divider>
                    <si-click-event v-model:event="element.customFeature" />
                </template>
            </si-collapse-group>
        </el-collapse-item>
    </el-collapse>
</template>

<script>
import { defineComponent, toRefs, computed } from 'vue'
import {
    SiClickEvent,
    SiCollapseGroup
} from '@/components/setting-pane/setting-item'
export default defineComponent({
    name: 'AnnounceContent',
    components: {
        SiClickEvent,
        SiCollapseGroup
    },
    props: {
        widget: {
            type: Object,
            default: () => ({})
        }
    },
    setup(props) {
        const { widget } = toRefs(props)

        const list = computed({
            get: () => widget.value.widgetData.eles.content || [],
            set: val => widget.value.widgetData.eles.content = val
        })

        const getAddData = () => {
            return {
                secContent: '公告内容',
                customFeature: {}
            }
        }

        return {
            widget,
            list,
            getAddData
        }
    }
})
</script>

<style lang="less" scoped>
.row-wrap {
    display: flex;
    align-items: center;
    .left-wrap {
        margin-right: 10px;
    }
    .right-wrap {
        // 
    }
}
</style>